
// Open MoneySpinner Suite v1
// An open source business management software system written in Java and MySQL
// Recommended IDE is NetBeans IDE 7.0.1
// Support Web Site: http://www.milliscript.com
//
// Copyright (C) 2014, Abiodun Aremu, Ibadan/NIGERIA.
// Open MoneySpinner Suite is distributed under the terms of the Apache License version 2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package openmoneyspinnersuite;

/**
 *
 * @author Abiodun Aremu
 */

import java.awt.*;
import javax.swing.*;
import java.sql.*;
import java.io.*;
import javax.imageio.*;
import javax.imageio.stream.*;
import java.awt.image.*;
import java.util.*;

final class Employee extends javax.swing.JInternalFrame {
    
    Systems systems=new Systems();
    PreparedStatement statement;
    ResultSet result;
    ResultSet pictureResult;
    String[] dbDesignation;
    String[] dbBank;
    String[] dbDepartment;
    Thread employeeThread=new Thread();
    Thread employeeTitleThread=new Thread();


    /** Creates new form NewCreditOrder */
     Employee() {
        initComponents();
        
        /* Execute submit thread */
        employeeThread=new Thread(new Runnable() {
            public void run() {
                disableControls();
                resetCountry();
                resetDepartment();
                resetDesignation();
                resetBank();
                resetDobMonth();
                resetAptMonth();
                resetDobYear();
                resetAptYear();
            }
        });
        employeeTitleThread=new Thread(new Runnable() {
            public void run() {
                while(employeeThread.isAlive())setProcessingTitle(employeeTitleThread);
                enableControls();
                System.out.println("employeeThread stopped runing.");
            }
        });
        employeeThread.start();
        employeeTitleThread.start();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jEmployeePanel = new javax.swing.JPanel();
        firstnameTextField = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        lastnameTextField = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        middlenameTextField = new javax.swing.JTextField();
        registerButton = new javax.swing.JButton();
        cityTextField = new javax.swing.JTextField();
        phoneTextField = new javax.swing.JTextField();
        zipTextField = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        sexComboBox = new javax.swing.JComboBox();
        bankComboBox = new javax.swing.JComboBox();
        departmentComboBox = new javax.swing.JComboBox();
        designationComboBox = new javax.swing.JComboBox();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        accountnumberTextField = new javax.swing.JTextField();
        jLabel14 = new javax.swing.JLabel();
        titleComboBox = new javax.swing.JComboBox();
        jLabel15 = new javax.swing.JLabel();
        jCountryComboBox = new javax.swing.JComboBox();
        jLabel16 = new javax.swing.JLabel();
        stateTextField = new javax.swing.JTextField();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        addressTextField = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        cancelButton = new javax.swing.JButton();
        dobMonthComboBox = new javax.swing.JComboBox();
        dobDayComboBox = new javax.swing.JComboBox();
        dobYearComboBox = new javax.swing.JComboBox();
        aptMonthComboBox = new javax.swing.JComboBox();
        aptDayComboBox = new javax.swing.JComboBox();
        aptYearComboBox = new javax.swing.JComboBox();
        statusComboBox = new javax.swing.JComboBox();
        jLabel19 = new javax.swing.JLabel();

        setClosable(true);
        setResizable(true);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(openmoneyspinnersuite.OpenMS_Finance_App.class).getContext().getResourceMap(Employee.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setFrameIcon(resourceMap.getIcon("Form.frameIcon")); // NOI18N
        setName("Form"); // NOI18N
        setVisible(true);

        jEmployeePanel.setName("jEmployeePanel"); // NOI18N

        firstnameTextField.setText(resourceMap.getString("firstnameTextField.text")); // NOI18N
        firstnameTextField.setName("firstnameTextField"); // NOI18N
        firstnameTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                firstnameTextFieldActionPerformed(evt);
            }
        });
        firstnameTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                firstnameTextFieldKeyTyped(evt);
            }
        });

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        lastnameTextField.setText(resourceMap.getString("lastnameTextField.text")); // NOI18N
        lastnameTextField.setName("lastnameTextField"); // NOI18N
        lastnameTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                lastnameTextFieldActionPerformed(evt);
            }
        });
        lastnameTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                lastnameTextFieldKeyTyped(evt);
            }
        });

        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        middlenameTextField.setName("middlenameTextField"); // NOI18N
        middlenameTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                middlenameTextFieldActionPerformed(evt);
            }
        });
        middlenameTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                middlenameTextFieldKeyTyped(evt);
            }
        });

        registerButton.setFont(resourceMap.getFont("registerButton.font")); // NOI18N
        registerButton.setIcon(resourceMap.getIcon("registerButton.icon")); // NOI18N
        registerButton.setText(resourceMap.getString("registerButton.text")); // NOI18N
        registerButton.setName("registerButton"); // NOI18N
        registerButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                registerButtonActionPerformed(evt);
            }
        });

        cityTextField.setName("cityTextField"); // NOI18N
        cityTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cityTextFieldActionPerformed(evt);
            }
        });
        cityTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                cityTextFieldKeyTyped(evt);
            }
        });

        phoneTextField.setName("phoneTextField"); // NOI18N
        phoneTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                phoneTextFieldActionPerformed(evt);
            }
        });
        phoneTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                phoneTextFieldKeyTyped(evt);
            }
        });

        zipTextField.setName("zipTextField"); // NOI18N
        zipTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                zipTextFieldActionPerformed(evt);
            }
        });
        zipTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                zipTextFieldKeyTyped(evt);
            }
        });

        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N

        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N

        jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N
        jLabel8.setName("jLabel8"); // NOI18N

        jLabel9.setText(resourceMap.getString("jLabel9.text")); // NOI18N
        jLabel9.setName("jLabel9"); // NOI18N

        jLabel10.setText(resourceMap.getString("jLabel10.text")); // NOI18N
        jLabel10.setName("jLabel10"); // NOI18N

        jLabel11.setText(resourceMap.getString("jLabel11.text")); // NOI18N
        jLabel11.setName("jLabel11"); // NOI18N

        sexComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-- Select --", "M", "F" }));
        sexComboBox.setName("sexComboBox"); // NOI18N

        bankComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-- Select --", "Item 2", "Item 3", "Item 4" }));
        bankComboBox.setName("bankComboBox"); // NOI18N
        bankComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bankComboBoxActionPerformed(evt);
            }
        });

        departmentComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-- Select --", "Item 2", "Item 3", "Item 4" }));
        departmentComboBox.setName("departmentComboBox"); // NOI18N
        departmentComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                departmentComboBoxActionPerformed(evt);
            }
        });

        designationComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-- Select --", "Item 2", "Item 3", "Item 4" }));
        designationComboBox.setName("designationComboBox"); // NOI18N
        designationComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                designationComboBoxActionPerformed(evt);
            }
        });

        jLabel12.setText(resourceMap.getString("jLabel12.text")); // NOI18N
        jLabel12.setName("jLabel12"); // NOI18N

        jLabel13.setText(resourceMap.getString("jLabel13.text")); // NOI18N
        jLabel13.setName("jLabel13"); // NOI18N

        accountnumberTextField.setName("accountnumberTextField"); // NOI18N
        accountnumberTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                accountnumberTextFieldActionPerformed(evt);
            }
        });
        accountnumberTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                accountnumberTextFieldKeyTyped(evt);
            }
        });

        jLabel14.setText(resourceMap.getString("jLabel14.text")); // NOI18N
        jLabel14.setName("jLabel14"); // NOI18N

        titleComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-- Select --", "Mr", "Mrs", "Miss" }));
        titleComboBox.setName("titleComboBox"); // NOI18N

        jLabel15.setText(resourceMap.getString("jLabel15.text")); // NOI18N
        jLabel15.setName("jLabel15"); // NOI18N

        jCountryComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-- Select --", "Item 2", "Item 3", "Item 4" }));
        jCountryComboBox.setName("jCountryComboBox"); // NOI18N

        jLabel16.setText(resourceMap.getString("jLabel16.text")); // NOI18N
        jLabel16.setName("jLabel16"); // NOI18N

        stateTextField.setName("stateTextField"); // NOI18N
        stateTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                stateTextFieldActionPerformed(evt);
            }
        });
        stateTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                stateTextFieldKeyTyped(evt);
            }
        });

        jLabel17.setText(resourceMap.getString("jLabel17.text")); // NOI18N
        jLabel17.setName("jLabel17"); // NOI18N

        jLabel18.setText(resourceMap.getString("jLabel18.text")); // NOI18N
        jLabel18.setName("jLabel18"); // NOI18N

        addressTextField.setName("addressTextField"); // NOI18N
        addressTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addressTextFieldActionPerformed(evt);
            }
        });
        addressTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                addressTextFieldKeyTyped(evt);
            }
        });

        jLabel1.setFont(resourceMap.getFont("jLabel1.font")); // NOI18N
        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        cancelButton.setFont(resourceMap.getFont("cancelButton.font")); // NOI18N
        cancelButton.setIcon(resourceMap.getIcon("cancelButton.icon")); // NOI18N
        cancelButton.setText(resourceMap.getString("cancelButton.text")); // NOI18N
        cancelButton.setName("cancelButton"); // NOI18N
        cancelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelButtonActionPerformed(evt);
            }
        });

        dobMonthComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-- Month --" }));
        dobMonthComboBox.setName("dobMonthComboBox"); // NOI18N
        dobMonthComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                dobMonthComboBoxActionPerformed(evt);
            }
        });

        dobDayComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-- Day --" }));
        dobDayComboBox.setName("dobDayComboBox"); // NOI18N

        dobYearComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-- Year --" }));
        dobYearComboBox.setName("dobYearComboBox"); // NOI18N

        aptMonthComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-- Month --" }));
        aptMonthComboBox.setName("aptMonthComboBox"); // NOI18N
        aptMonthComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                aptMonthComboBoxActionPerformed(evt);
            }
        });

        aptDayComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-- Day --" }));
        aptDayComboBox.setName("aptDayComboBox"); // NOI18N

        aptYearComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-- Year --" }));
        aptYearComboBox.setName("aptYearComboBox"); // NOI18N

        statusComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-- Select --", "Single", "Married", "Divorced" }));
        statusComboBox.setName("statusComboBox"); // NOI18N

        jLabel19.setText(resourceMap.getString("jLabel19.text")); // NOI18N
        jLabel19.setName("jLabel19"); // NOI18N

        javax.swing.GroupLayout jEmployeePanelLayout = new javax.swing.GroupLayout(jEmployeePanel);
        jEmployeePanel.setLayout(jEmployeePanelLayout);
        jEmployeePanelLayout.setHorizontalGroup(
            jEmployeePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jEmployeePanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jEmployeePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jEmployeePanelLayout.createSequentialGroup()
                        .addGroup(jEmployeePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jEmployeePanelLayout.createSequentialGroup()
                                .addGroup(jEmployeePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel15)
                                    .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel2)
                                    .addComponent(jLabel10)
                                    .addComponent(jLabel18)
                                    .addComponent(jLabel17)
                                    .addComponent(jLabel12)
                                    .addComponent(jLabel11))
                                .addGap(5, 5, 5)
                                .addGroup(jEmployeePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(titleComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(middlenameTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 298, Short.MAX_VALUE)
                                    .addComponent(lastnameTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 298, Short.MAX_VALUE)
                                    .addComponent(addressTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 298, Short.MAX_VALUE)
                                    .addComponent(stateTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 298, Short.MAX_VALUE)
                                    .addComponent(firstnameTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 298, Short.MAX_VALUE)
                                    .addComponent(phoneTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 298, Short.MAX_VALUE)
                                    .addGroup(jEmployeePanelLayout.createSequentialGroup()
                                        .addComponent(dobMonthComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(dobDayComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(dobYearComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addGap(82, 82, 82))
                            .addGroup(jEmployeePanelLayout.createSequentialGroup()
                                .addComponent(jLabel14)
                                .addGap(4, 4, 4)
                                .addComponent(aptMonthComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(aptDayComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(aptYearComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(1, 1, 1)
                        .addGroup(jEmployeePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel3)
                            .addComponent(jLabel13)
                            .addComponent(jLabel16)
                            .addComponent(jLabel5)
                            .addComponent(jLabel7)
                            .addComponent(jLabel6)
                            .addComponent(jLabel8)
                            .addComponent(jLabel9)
                            .addComponent(jLabel19))
                        .addGap(18, 18, 18)
                        .addGroup(jEmployeePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(statusComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(departmentComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jEmployeePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(jCountryComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(zipTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 165, Short.MAX_VALUE)
                                .addComponent(sexComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(cityTextField)
                                .addComponent(accountnumberTextField)
                                .addComponent(bankComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(designationComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(71, 71, 71))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jEmployeePanelLayout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 285, Short.MAX_VALUE)
                        .addComponent(registerButton)
                        .addGap(18, 18, 18)
                        .addComponent(cancelButton)
                        .addGap(110, 110, 110))))
        );
        jEmployeePanelLayout.setVerticalGroup(
            jEmployeePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jEmployeePanelLayout.createSequentialGroup()
                .addGap(23, 23, 23)
                .addGroup(jEmployeePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel15)
                    .addComponent(titleComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel19)
                    .addComponent(statusComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jEmployeePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jEmployeePanelLayout.createSequentialGroup()
                        .addGroup(jEmployeePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel4)
                            .addComponent(firstnameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jEmployeePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(middlenameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel2))
                        .addGap(17, 17, 17)
                        .addGroup(jEmployeePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lastnameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel10))
                        .addGap(18, 18, 18)
                        .addGroup(jEmployeePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel18)
                            .addComponent(addressTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jEmployeePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel17)
                            .addComponent(stateTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jEmployeePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel12)
                            .addComponent(phoneTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(20, 20, 20)
                        .addGroup(jEmployeePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel11)
                            .addComponent(dobMonthComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(dobDayComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(dobYearComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jEmployeePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel14)
                            .addComponent(aptMonthComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(aptDayComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(aptYearComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jEmployeePanelLayout.createSequentialGroup()
                        .addGroup(jEmployeePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(zipTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel6))
                        .addGap(18, 18, 18)
                        .addGroup(jEmployeePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(cityTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel7))
                        .addGap(17, 17, 17)
                        .addGroup(jEmployeePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jCountryComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel5))
                        .addGap(14, 14, 14)
                        .addGroup(jEmployeePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(sexComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel16))
                        .addGap(18, 18, 18)
                        .addGroup(jEmployeePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(accountnumberTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel13))
                        .addGap(18, 18, 18)
                        .addGroup(jEmployeePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(bankComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel3))
                        .addGap(18, 18, 18)
                        .addGroup(jEmployeePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(departmentComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel8))
                        .addGap(18, 18, 18)
                        .addGroup(jEmployeePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(designationComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel9))))
                .addGap(44, 44, 44)
                .addGroup(jEmployeePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(registerButton, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cancelButton, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jEmployeePanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jEmployeePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void lastnameTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lastnameTextFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_lastnameTextFieldActionPerformed

    private void firstnameTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_firstnameTextFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_firstnameTextFieldActionPerformed

    private void middlenameTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_middlenameTextFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_middlenameTextFieldActionPerformed

    private void cityTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cityTextFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cityTextFieldActionPerformed

    private void phoneTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_phoneTextFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_phoneTextFieldActionPerformed

    private void zipTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_zipTextFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_zipTextFieldActionPerformed

    private void accountnumberTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_accountnumberTextFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_accountnumberTextFieldActionPerformed

    private void stateTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stateTextFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_stateTextFieldActionPerformed

    private void addressTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addressTextFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_addressTextFieldActionPerformed

    private void registerButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_registerButtonActionPerformed
        // TODO add your handling code here:
        String value=phoneTextField.getText().trim();
        String value2=accountnumberTextField.getText().trim();

        int x=value.length();
        int xx=value2.length();

        int y=0;
        int yy=0;

        char[] ch=value.toCharArray();
        char[] ch2=value2.toCharArray();

        if(titleComboBox.getSelectedItem().equals("-- Select --"))
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Please Select Employee's Title ","ERROR !",JOptionPane.ERROR_MESSAGE);
            return;
        }
        if(statusComboBox.getSelectedItem().equals("-- Select --"))
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Please Select Employee's Status ","ERROR !",JOptionPane.ERROR_MESSAGE);
            return;
        }
        if(firstnameTextField.getText().trim().isEmpty())
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Please Enter Employee's First Name ","ERROR !",JOptionPane.ERROR_MESSAGE);
            return;
        }
        if(lastnameTextField.getText().trim().isEmpty())
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Please Enter Employee's Last Name ","ERROR !",JOptionPane.ERROR_MESSAGE);
            return;
        }

        if(addressTextField.getText().trim().isEmpty())
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Please Enter Employee's Address ","ERROR !",JOptionPane.ERROR_MESSAGE);
            return;
        }
        if(stateTextField.getText().trim().isEmpty())
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Please Enter Employee's State ","ERROR !",JOptionPane.ERROR_MESSAGE);
            return;
        }
        if(phoneTextField.getText().trim().isEmpty())
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Please Enter Employee's Phone Number ","ERROR !",JOptionPane.ERROR_MESSAGE);
            return;
        }

        while(y<x)
        {
            try
            {
                if(!Character.isDigit(ch[y]))
                {
                JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Employee's Phone Number Must Be in Digits","ERROR !",JOptionPane.ERROR_MESSAGE);
                return;
                }
            }
            catch(Exception e)
            {
                JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Phone Number Can Not Contain Alphabets","ERROR !",JOptionPane.ERROR_MESSAGE);
                phoneTextField.setText("");
                System.out.println(e+" Non int available in "+value+" non int is "+ch[y]);
                return;
            }
        y++;
        }

        if(departmentComboBox.getSelectedItem().equals("-- Select --"))
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Please Select Employee's Department ","ERROR !",JOptionPane.ERROR_MESSAGE);
            return;
        }
        if(designationComboBox.getSelectedItem().equals("-- Select --"))
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Please Select Employee's Designation ","ERROR !",JOptionPane.ERROR_MESSAGE);
            return;
        }
        if(zipTextField.getText().trim().isEmpty())
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Please Enter Employee's Zip Code ","ERROR !",JOptionPane.ERROR_MESSAGE);
            return;
        }
        if(cityTextField.getText().trim().isEmpty())
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Please Enter Employee's City ","ERROR !",JOptionPane.ERROR_MESSAGE);
            return;
        }
        if(jCountryComboBox.getSelectedItem().equals("-- Select --"))
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Please Select Employee's Country ","ERROR !",JOptionPane.ERROR_MESSAGE);
            return;
        }
        if(sexComboBox.getSelectedItem().equals("-- Select --"))
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Please Select Employee's Sex ","ERROR !",JOptionPane.ERROR_MESSAGE);
            return;
        }
        if(aptMonthComboBox.getSelectedItem().equals("-- Month --"))
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Please Select Employee's Appointment Month ","ERROR !",JOptionPane.ERROR_MESSAGE);
            return;
        }
        if(aptDayComboBox.getSelectedItem().equals("-- Day --"))
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Please Select Employee's Appointment Day ","ERROR !",JOptionPane.ERROR_MESSAGE);
            return;
        }
        if(aptYearComboBox.getSelectedItem().equals("-- Year --"))
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Please Select Employee's Appointment Year ","ERROR !",JOptionPane.ERROR_MESSAGE);
            return;
        }
        if(dobMonthComboBox.getSelectedItem().equals("-- Month --"))
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Please Select Employee's DOB Month ","ERROR !",JOptionPane.ERROR_MESSAGE);
            return;
        }
        if(dobDayComboBox.getSelectedItem().equals("-- Day --"))
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Please Select Employee's DOB Day ","ERROR !",JOptionPane.ERROR_MESSAGE);
            return;
        }
        if(dobYearComboBox.getSelectedItem().equals("-- Year --"))
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Please Select Employee's DOB Year ","ERROR !",JOptionPane.ERROR_MESSAGE);
            return;
        }
        if(!accountnumberTextField.getText().trim().isEmpty())
        {
            while(yy<xx)
            {
                try
                {
                    if(!Character.isDigit(ch2[yy]))
                    {
                    JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Employee's Account Number Must Be in Digits","ERROR !",JOptionPane.ERROR_MESSAGE);
                    return;
                    }
                }
                catch(Exception e)
                {
                    JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Account Number Can Not Contain Alphabets","ERROR !",JOptionPane.ERROR_MESSAGE);
                    accountnumberTextField.setText("");
                    System.out.println(e+" Non int available in "+value2+" non int is "+ch2[yy]);
                    return;
                }

                yy++;
            }

        }
            /* Execute submit thread */
            employeeThread=new Thread(new Runnable() {
                public void run() {
                    disableControls();
                    submitData();
                    resetField();
                }
            });
            employeeTitleThread=new Thread(new Runnable() {
                public void run() {
                    while(employeeThread.isAlive())setProcessingTitle(employeeTitleThread);
                    enableControls();
                    System.out.println("employeeThread stopped runing.");
                }
            });
            employeeThread.start();
            employeeTitleThread.start();
        
    }//GEN-LAST:event_registerButtonActionPerformed
                               
    private void setProcessingTitle(Thread thread)
    {
        try{
            this.setTitle("::. New Employee - Processing Request");
            thread.sleep(500);
            this.setTitle("::. New Employee - Processing Request.");
            thread.sleep(500);
            this.setTitle("::. New Employee - Processing Request..");
            thread.sleep(500);
            this.setTitle("::. New Employee - Processing Request...");
            thread.sleep(500);
        }catch(Exception e){System.out.println("Title thread"+e);}
    }
    private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
        
        if(employeeThread.isAlive())
        {
            try{
                employeeThread.stop();
                employeeTitleThread.stop();
                System.out.println("Threads successfully stopped.");
            }catch(Exception e){System.out.println("Thread stopping error: "+e);}
            this.setTitle("::. New Employee");
            enableControls();
        }
        else
        this.dispose();
    }//GEN-LAST:event_cancelButtonActionPerformed

    private void dobMonthComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dobMonthComboBoxActionPerformed
        // TODO add your handling code here:
        String dobMonth=dobMonthComboBox.getSelectedItem().toString();
        
        if(dobMonth.equals("-- Month --"))
        {
        }
        else
        {
            resetDobDay(dobMonth);
        }

    }//GEN-LAST:event_dobMonthComboBoxActionPerformed

    private void aptMonthComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aptMonthComboBoxActionPerformed
        // TODO add your handling code here:
        String aptMonth=aptMonthComboBox.getSelectedItem().toString();

        if(aptMonth.equals("-- Month --"))
        {
        }
        else
        {
            resetAptDay(aptMonth);
        }

    }//GEN-LAST:event_aptMonthComboBoxActionPerformed

    private void departmentComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_departmentComboBoxActionPerformed
        // TODO add your handling code here:
        String department=departmentComboBox.getSelectedItem().toString();
        if(department.equals("-- Select --"))
        {
            resetDepartment();
        }

    }//GEN-LAST:event_departmentComboBoxActionPerformed

    private void designationComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_designationComboBoxActionPerformed
        // TODO add your handling code here:
        String designation=designationComboBox.getSelectedItem().toString();
        if(designation.equals("-- Select --"))
        {
            resetDesignation();
        }
    }//GEN-LAST:event_designationComboBoxActionPerformed

    private void bankComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bankComboBoxActionPerformed
        // TODO add your handling code here:
        String bank=bankComboBox.getSelectedItem().toString();
        if(bank.equals("-- Select --"))
        {
            resetBank();
        }
    }//GEN-LAST:event_bankComboBoxActionPerformed

    private void firstnameTextFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_firstnameTextFieldKeyTyped
        // TODO add your handling code here:
        String value=firstnameTextField.getText();
        if(value.length()>19)
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Maximum Number of Character (20) Exceeded ","ERROR !",JOptionPane.ERROR_MESSAGE);
            String newValue=String.copyValueOf(value.toCharArray(),0, 19);
            firstnameTextField.setText(newValue);
        }

    }//GEN-LAST:event_firstnameTextFieldKeyTyped

    private void middlenameTextFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_middlenameTextFieldKeyTyped
        // TODO add your handling code here:
        String value=middlenameTextField.getText();
        if(value.length()>19)
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Maximum Number of Character (20) Exceeded ","ERROR !",JOptionPane.ERROR_MESSAGE);
            String newValue=String.copyValueOf(value.toCharArray(),0, 19);
            middlenameTextField.setText(newValue);
        }

    }//GEN-LAST:event_middlenameTextFieldKeyTyped

    private void lastnameTextFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_lastnameTextFieldKeyTyped
        // TODO add your handling code here:
        String value=lastnameTextField.getText();
        if(value.length()>19)
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Maximum Number of Character (20) Exceeded ","ERROR !",JOptionPane.ERROR_MESSAGE);
            String newValue=String.copyValueOf(value.toCharArray(),0, 19);
            lastnameTextField.setText(newValue);
        }

    }//GEN-LAST:event_lastnameTextFieldKeyTyped

    private void addressTextFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_addressTextFieldKeyTyped
        // TODO add your handling code here:
        String value=addressTextField.getText();
        if(value.length()>79)
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Maximum Number of Character (80) Exceeded ","ERROR !",JOptionPane.ERROR_MESSAGE);
            String newValue=String.copyValueOf(value.toCharArray(),0, 79);
            addressTextField.setText(newValue);
        }

    }//GEN-LAST:event_addressTextFieldKeyTyped

    private void stateTextFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_stateTextFieldKeyTyped
        // TODO add your handling code here:
        String value=stateTextField.getText();
        if(value.length()>14)
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Maximum Number of Character (15) Exceeded ","ERROR !",JOptionPane.ERROR_MESSAGE);
            String newValue=String.copyValueOf(value.toCharArray(),0, 14);
            stateTextField.setText(newValue);
        }
    }//GEN-LAST:event_stateTextFieldKeyTyped

    private void phoneTextFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_phoneTextFieldKeyTyped
        // TODO add your handling code here:
        String value=phoneTextField.getText();
        if(value.length()>14)
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Maximum Number of Character (15) Exceeded ","ERROR !",JOptionPane.ERROR_MESSAGE);
            String newValue=String.copyValueOf(value.toCharArray(),0, 14);
            phoneTextField.setText(newValue);
        }
    }//GEN-LAST:event_phoneTextFieldKeyTyped

    private void zipTextFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_zipTextFieldKeyTyped
        // TODO add your handling code here:
        String value=zipTextField.getText();
        if(value.length()>7)
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Maximum Number of Character (8) Exceeded ","ERROR !",JOptionPane.ERROR_MESSAGE);
            String newValue=String.copyValueOf(value.toCharArray(),0,7);
            zipTextField.setText(newValue);
        }
    }//GEN-LAST:event_zipTextFieldKeyTyped

    private void cityTextFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_cityTextFieldKeyTyped
        // TODO add your handling code here:
        String value=cityTextField.getText();
        if(value.length()>14)
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Maximum Number of Character (15) Exceeded ","ERROR !",JOptionPane.ERROR_MESSAGE);
            String newValue=String.copyValueOf(value.toCharArray(),0, 14);
            cityTextField.setText(newValue);
        }
    }//GEN-LAST:event_cityTextFieldKeyTyped

    private void accountnumberTextFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_accountnumberTextFieldKeyTyped
        // TODO add your handling code here:
        String value=accountnumberTextField.getText();
        if(value.length()>39)
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Maximum Number of Character (40) Exceeded ","ERROR !",JOptionPane.ERROR_MESSAGE);
            String newValue=String.copyValueOf(value.toCharArray(),0, 39);
            accountnumberTextField.setText(newValue);
        }
    }//GEN-LAST:event_accountnumberTextFieldKeyTyped
   
   
     void resetDobYear()
    {
        String[] year=systems.getYears(1920);
        year[0]="-- Year --";
        dobYearComboBox.setModel(new DefaultComboBoxModel(year));
    }
     void resetAptYear()
    {
        String[] year=systems.getYears(1920);
        year[0]="-- Year --";
        aptYearComboBox.setModel(new DefaultComboBoxModel(year));
    }
     void resetCountry()
    {
        String[] country=systems.getTableDataArray(OpenMSApp.Database_A,"Country",2);
        country[0]="-- Select --";

        jCountryComboBox.setModel(new DefaultComboBoxModel(country));
        jCountryComboBox.setSelectedItem("NIGERIA");
    }
     void resetDobMonth()
    {
        String[] month=systems.getMonthArray();
        month[0]="-- Month --";

        dobMonthComboBox.setModel(new DefaultComboBoxModel(month));

    }
     void resetAptMonth()
    {
        String[] month=systems.getMonthArray();
        month[0]="-- Month --";

        aptMonthComboBox.setModel(new DefaultComboBoxModel(month));

    }
     void resetDepartment()
    {
        String[] department=systems.getTableDataArray(OpenMSApp.Database_A,"Department",2);
        department[0]="-- Select --";

        departmentComboBox.setModel(new DefaultComboBoxModel(department));

    }
     void resetDesignation()
    {
        String[] designation=systems.getTableDataArray(OpenMSApp.Database_A,"Designation",2);
        designation[0]="-- Select --";

        designationComboBox.setModel(new DefaultComboBoxModel(designation));

    }
     void resetBank()
    {
        String[] bank=systems.getTableDataArray(OpenMSApp.Database_A,"bank",2);
        bank[0]="-- Select --";

        bankComboBox.setModel(new DefaultComboBoxModel(bank));

    }
     void resetAptDay(String aptMonth)
    { 
        String[] aptDay={"-- Day --"};
        if(aptMonth.isEmpty())
        {
            aptDayComboBox.setModel(new DefaultComboBoxModel(aptDay));
        }
        else
        {
            aptDay=systems.getDays(aptMonth);
            aptDay[0]="-- Day --";
            aptDayComboBox.setModel(new DefaultComboBoxModel(aptDay));
        }
    
    }
     void resetDobDay(String Month)
    { 
        String[] dobDay={"-- Day --"};
        if(Month.isEmpty())
        {
            dobDayComboBox.setModel(new DefaultComboBoxModel(dobDay));
        }
        else
        {
            dobDay=systems.getDays(Month);
            dobDay[0]="-- Day --";
            dobDayComboBox.setModel(new DefaultComboBoxModel(dobDay));
        }
    
    }
    void resetField()
    {
        firstnameTextField.setText("");
        middlenameTextField.setText("");
        lastnameTextField.setText("");
        addressTextField.setText("");
        cityTextField.setText("");
        stateTextField.setText("");
        phoneTextField.setText("");
        accountnumberTextField.setText("");
        zipTextField.setText("");
        sexComboBox.setSelectedItem("-- Select --");
        titleComboBox.setSelectedItem("-- Select --");
        statusComboBox.setSelectedItem("-- Select --");
        resetBank();
        resetCountry();
        resetAptMonth();
        resetAptYear();
        resetDobMonth();
        resetDobYear();
        resetDepartment();
        resetDesignation();
        resetAptDay("");
        resetDobDay("");
    }
    private void disableControls()
    {
        firstnameTextField.setEnabled(false);
        middlenameTextField.setEnabled(false);
        lastnameTextField.setEnabled(false);
        addressTextField.setEnabled(false);
        cityTextField.setEnabled(false);
        stateTextField.setEnabled(false);
        phoneTextField.setEnabled(false);
        accountnumberTextField.setEnabled(false);
        zipTextField.setEnabled(false);
        sexComboBox.setEnabled(false);
        titleComboBox.setEnabled(false);
        statusComboBox.setEnabled(false);
        
        bankComboBox.setEnabled(false);
        
        jCountryComboBox.setEnabled(false);
        
        aptMonthComboBox.setEnabled(false);
        
        aptYearComboBox.setEnabled(false);
        
        dobMonthComboBox.setEnabled(false);
        
        dobYearComboBox.setEnabled(false);
        
        departmentComboBox.setEnabled(false);
        
        designationComboBox.setEnabled(false);
        
        aptDayComboBox.setEnabled(false);
        
        dobDayComboBox.setEnabled(false);
    }
    private void enableControls()
    {
        firstnameTextField.setEnabled(true);
        middlenameTextField.setEnabled(true);
        lastnameTextField.setEnabled(true);
        addressTextField.setEnabled(true);
        cityTextField.setEnabled(true);
        stateTextField.setEnabled(true);
        phoneTextField.setEnabled(true);
        accountnumberTextField.setEnabled(true);
        zipTextField.setEnabled(true);
        sexComboBox.setEnabled(true);
        titleComboBox.setEnabled(true);
        statusComboBox.setEnabled(true);
        
        bankComboBox.setEnabled(true);
        
        jCountryComboBox.setEnabled(true);
        
        aptMonthComboBox.setEnabled(true);
        
        aptYearComboBox.setEnabled(true);
        
        dobMonthComboBox.setEnabled(true);
        
        dobYearComboBox.setEnabled(true);
        
        departmentComboBox.setEnabled(true);
        
        designationComboBox.setEnabled(true);
        
        aptDayComboBox.setEnabled(true);
        
        dobDayComboBox.setEnabled(true);
        this.setTitle("::. New Employee");
    }
     void reset()
    {
        resetField();
    }
     void resetCombo()
    {
        resetBank();
        resetCountry();
        resetAptMonth();
        resetAptYear();
        resetDobMonth();
        resetDobYear();
        resetDepartment();
        resetDesignation();
        resetAptDay("");
        resetDobDay("");
        sexComboBox.setSelectedItem("-- Select --");
        titleComboBox.setSelectedItem("-- Select --");
        statusComboBox.setSelectedItem("-- Select --");
    }
     String getBank()
    {
        String bank=String.valueOf(bankComboBox.getSelectedItem());
        
        if(bank.equals("-- Select --"))
        {
            bank="";
        }
        return bank;
    }
     void submitData()
    {
        //Connect.createMSSQLConnection();
        Connect.changeDB(OpenMSApp.Database_A);
        statement=Connect.createStatement(Connect.procInit+" prnInsEmployee"+Connect.procInitStart+"?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?"+Connect.procInitEnd);
         try{
                    statement.setString(1,firstnameTextField.getText().trim());
                    statement.setString(2,middlenameTextField.getText().trim());
                    statement.setString(3,lastnameTextField.getText().trim());
                    statement.setString(4,String.valueOf(titleComboBox.getSelectedItem()).trim());
                    statement.setString(5,String.valueOf(statusComboBox.getSelectedItem()).trim());
                    statement.setString(6,addressTextField.getText().trim());
                    statement.setString(7,cityTextField.getText().trim());
                    statement.setString(8,stateTextField.getText().trim());
                    statement.setString(9,String.valueOf(jCountryComboBox.getSelectedItem()).trim());
                    statement.setString(10,zipTextField.getText().trim());
                    statement.setString(11,String.valueOf(sexComboBox.getSelectedItem()).trim());
                    statement.setString(12,new String(String.valueOf(dobYearComboBox.getSelectedItem()).trim())+"-"+systems.getMonthDigit(String.valueOf(dobMonthComboBox.getSelectedItem()).trim())+"-"+String.valueOf(dobDayComboBox.getSelectedItem()).trim());
                    statement.setString(13,phoneTextField.getText().trim());
                    statement.setString(14,String.valueOf(departmentComboBox.getSelectedItem()).trim());
                    statement.setString(15,String.valueOf(designationComboBox.getSelectedItem()).trim());
                    statement.setString(16,getBank().trim());
                    statement.setString(17,accountnumberTextField.getText().trim());
                    statement.setString(18,new String(String.valueOf(aptYearComboBox.getSelectedItem()).trim())+"-"+systems.getMonthDigit(String.valueOf(aptMonthComboBox.getSelectedItem()).trim())+"-"+String.valueOf(aptDayComboBox.getSelectedItem()).trim());

            }
            catch(Exception e)
            {
            System.out.println("Employee.submitData() gave error ! "+e);
            }
        Connect.alert="Y";
        Connect.executeUpdateStatement(statement);
        Connect.closeConnection();
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField accountnumberTextField;
    private javax.swing.JTextField addressTextField;
    private javax.swing.JComboBox aptDayComboBox;
    private javax.swing.JComboBox aptMonthComboBox;
    private javax.swing.JComboBox aptYearComboBox;
    private javax.swing.JComboBox bankComboBox;
    private javax.swing.JButton cancelButton;
    private javax.swing.JTextField cityTextField;
    private javax.swing.JComboBox departmentComboBox;
    private javax.swing.JComboBox designationComboBox;
    private javax.swing.JComboBox dobDayComboBox;
    private javax.swing.JComboBox dobMonthComboBox;
    private javax.swing.JComboBox dobYearComboBox;
    private javax.swing.JTextField firstnameTextField;
    private javax.swing.JComboBox jCountryComboBox;
    private javax.swing.JPanel jEmployeePanel;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JTextField lastnameTextField;
    private javax.swing.JTextField middlenameTextField;
    private javax.swing.JTextField phoneTextField;
    private javax.swing.JButton registerButton;
    private javax.swing.JComboBox sexComboBox;
    private javax.swing.JTextField stateTextField;
    private javax.swing.JComboBox statusComboBox;
    private javax.swing.JComboBox titleComboBox;
    private javax.swing.JTextField zipTextField;
    // End of variables declaration//GEN-END:variables

}
